package com.tywj.panda.customer.common.view.dialog

import android.os.SystemClock
import androidx.appcompat.widget.AppCompatButton
import com.afollestad.materialdialogs.MaterialDialog
import com.tywj.panda.customer.common.R
import com.tywj.lib.core.common.util.ResourcesUtil
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread

/**
 * <pre>
 *     author : June Yang
 *     time   : 2019/01/13
 *     desc   : MaterialDialog扩展
 *     version: 1.0.0
 * </pre>
 */
fun MaterialDialog.showByCZConfig(): MaterialDialog {
    show()

    doAsync {
        SystemClock.sleep(50L)
        uiThread {
            val positiveButton = findViewById<AppCompatButton>(R.id.md_button_positive)
            val negativeButton = findViewById<AppCompatButton>(R.id.md_button_negative)
            val neutralButton = findViewById<AppCompatButton>(R.id.md_button_neutral)

            positiveButton.setTextColor(ResourcesUtil.getColor(R.color.common_font_red))
            negativeButton.setTextColor(ResourcesUtil.getColor(R.color.common_font_black))
            neutralButton.setTextColor(ResourcesUtil.getColor(R.color.common_font_black))
        }
    }

    return this
}